"""
@Filename: testcase/test_login
@Author: yoko
@Time: 2023/3/27 15:43
@Describe: ...
"""
from pprint import pprint

import allure
import pytest

from tools.assert_util import total_assert
from tools.unification_request import RequestUtil
from tools.operate_yaml import read_yaml
@allure.feature("模块名称：基础操作相关接口")
class Test_Login:
    @pytest.mark.parametrize("caseinfo",read_yaml('./testcase/test_Alogin_password.yaml'))
    @allure.story("接口名称：用户名密码登录")
    def test_login_password(self,base_url,caseinfo):
        """
        密码登录
        :return:
        """
        allure.dynamic.title(caseinfo['title'])
        caseinfo=RequestUtil().hot_loading(caseinfo)
        method=caseinfo['request']['method']
        url=base_url+caseinfo['request']['url']
        params=caseinfo['request']['params']
        headers=caseinfo['request']['headers']
        validate=caseinfo['validate']
        res=RequestUtil().uniform_request(method=method,url=url,params=params,headers=headers)
        print(res.json())
        total_assert(validate, res)
    @pytest.mark.parametrize('caseinfo',read_yaml('./testcase/test_bsend_verifity_code.yaml'))
    @allure.story("接口名称：获取手机验证码V2")
    def test_send_verifity_code(self,base_url,caseinfo):
        """
        发送短信验证码
        :param base_url:
        :return:
        """
        allure.dynamic.title(caseinfo['title'])
        caseinfo = RequestUtil().hot_loading(caseinfo)
        method = caseinfo['request']['method']
        url = base_url + caseinfo['request']['url']
        params = caseinfo['request']['params']
        headers = caseinfo['request']['headers']
        validate = caseinfo['validate']
        res=RequestUtil().uniform_request(method=method,url=url,params=params,headers=headers)
        print(res.json())
        total_assert(validate, res)
    @pytest.mark.parametrize('caseinfo',read_yaml('./testcase/test_resgiter_note.yaml'))
    @allure.story("接口名称：短信验证码登录")
    def test_login_note(self,base_url,caseinfo):
        """验证码登录/注册"""
        allure.dynamic.title(caseinfo['title'])
        caseinfo = RequestUtil().hot_loading(caseinfo)
        method = caseinfo['request']['method']
        url = base_url + caseinfo['request']['url']
        params = caseinfo['request']['params']
        headers = caseinfo['request']['headers']
        validate = caseinfo['validate']
        res=RequestUtil().uniform_request(method=method,url=url,params=params,headers=headers)
        print(res.json())
        total_assert(validate, res)